<?php namespace App\Http\Controllers;

use App\Models\Config;
use Illuminate\Http\Request;
use Zhuzhichao\IpLocationZh\Ip;

class ConfigController extends Controller
{

    public function __construct()
    {

    }

    public function show($res_id, Request $request)
    {
        $config = Config::where('res_id', $res_id)->first();
        if($config == null){
            return response()->json([]);
        }
        if (Ip::find($request->ip())[0] != '中国') {
            $config->check = false;
            $config->rate = false;
            $config->alert_title = 'Notice';
            $config->alert_message = 'For more game, press ok!';
            $config->alert_url = 'http://h.4399.com';
            $config->alert_delay = 60;
            return response()->json($config);
        }else{
            return response()->json($config);
        }
        return response()->json([]);
    }

}